<!DOCTYPE html>
<html>
<!--
Copyright 2007 The Closure Library Authors. All Rights Reserved.

Use of this source code is governed by the Apache License, Version 2.0.
See the COPYING file for details.
-->
<!--


 In reality, this response comes from a different domain.  For simplicity of
 testing, this response is one the same domain, while exercising the same
 functionality.
-->
<title>crossdomainrpc test response</title>
<body>
<script type="text/javascript" src="../base.js"></script>
<script type="text/javascript">
goog.require('goog.Uri.QueryData');
goog.require('goog.dom');
goog.require('goog.events.EventTarget');
goog.require('goog.json');
goog.require('goog.log');
goog.require('goog.net.EventType');
goog.require('goog.userAgent');
</script>
<script type="text/javascript" src="crossdomainrpc.js"></script>
<script type="text/javascript">
function createPayload(size) {
  var chars = [];
  for (var i = 0; i < size; i++) {
    chars.push('0');
  }
  return chars.join('');
};

var payload = createPayload(16 * 1024);

var currentDirectory = location.href.substring(
    0, location.href.lastIndexOf('/')
);

var echo = {};
echo[goog.net.CrossDomainRpc.PARAM_ECHO_REQUEST_ID] = 0;
echo[goog.net.CrossDomainRpc.PARAM_ECHO_DUMMY_URI] = goog.userAgent.EDGE_OR_IE ?
    currentDirectory + '/crossdomainrpc_test.gif' :
    currentDirectory + '/crossdomainrpc_test.css';

goog.net.CrossDomainRpc.sendResponse(
    '({"result":"' + payload + '"})',
    true,              // is JSON
    echo,              // parameters to echo back
    123,               // response code
    '{"a":1,"b":"2"}'  // response headers
);
</script>
</body>
</html>
